package com.weishu.service.impl;

import com.github.pagehelper.PageHelper;

import com.weishu.domain.Dynamicltem;
import com.weishu.domain.PremisesInfoEntity;
import com.weishu.mapper.LoupanMapper;
import com.weishu.service.LoupanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author huizhenfei
 * @Description //TODO qq231
 * @Date 20:53 2021/5/18
 * @Param
 * @return
 **/
@Service
public class LoupanServiceImpl implements LoupanService {
    @Autowired
    private LoupanMapper loupanDao;

    @Override
    public List<PremisesInfoEntity> getloupanlist(Map<String, Object> map, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PremisesInfoEntity> list=loupanDao.getloupanlist(map);

        return list;
    }

    @Override
    public int addone(PremisesInfoEntity premisesInfoEntity) {
        //添加楼盘
        Integer k=loupanDao.addone(premisesInfoEntity);
        Integer preid=premisesInfoEntity.getId();
        //周边设备
        List<Dynamicltem> dynamicltem = premisesInfoEntity.getDynamicltem();
        for (Dynamicltem dynamicltem1 : dynamicltem) {
             loupanDao.addzhoubian(dynamicltem1.getTotal(),dynamicltem1.getContent(),preid);
        }
        //公交设备
        List<Dynamicltem> dynamicltem2 = premisesInfoEntity.getDynamicltem2();
        for (Dynamicltem dynamicltem1 : dynamicltem2) {
            loupanDao.addjiaotong(dynamicltem1.getTotal(),dynamicltem1.getContent(),preid);
        }
        return k;


    }
}
